import com.cloudera.api.ApiRootResource;
import com.cloudera.api.ClouderaManagerClientBuilder;
import com.cloudera.api.DataView;
import com.cloudera.api.model.*;
import com.cloudera.api.v11.TimeSeriesResourceV11;
import com.cloudera.api.v30.HostsResourceV30;
import com.cloudera.api.v33.ClustersResourceV33;
import com.cloudera.api.v33.RootResourceV33;

import java.util.List;

public class CmTest01 {

    public static void main(String[] args) {
        String CMS_HOST = "10.87.229.25";
        int CMS_PORT = 7180;
        String CMS_USER = "admin";
        String CMS_PASSWORD = "admin";
        String CLUSTER_NAME = "Cluster";

        ApiRootResource build = new ClouderaManagerClientBuilder().withHost(CMS_HOST).withPort(CMS_PORT)
                .withUsernamePassword(CMS_USER, CMS_PASSWORD).build();


        String currentVersion = build.getCurrentVersion();
        System.out.println("currentVersion=="+currentVersion);
        RootResourceV33 rootResource = build.getRootV33();

        ClustersResourceV33 clustersResource = rootResource.getClustersResource();
        ApiClusterList clusterList = clustersResource.readClusters(DataView.EXPORT);
        List<ApiCluster> clusters = clusterList.getClusters();

        HostsResourceV30 hostsResource = rootResource.getHostsResource();


        TimeSeriesResourceV11 timeSeriesResource = rootResource.getTimeSeriesResource();


        for (ApiCluster clusterCluster: clusters) {
            String name = clusterCluster.getName();
            System.err.println(clusterCluster.getName());
            List<ApiService> services = clusterCluster.getServices();
            List<ApiDataContextRef> dataContextRefs = clusterCluster.getDataContextRefs();
            System.out.println();
        }
        ApiHostList apiHosts = rootResource.getHostsResource().readHosts(DataView.EXPORT_REDACTED);


    }
}
